<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="t" uri="http://myfaces.apache.org/tomahawk" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
</head>
<body>
<f:view>
    <h:form id="menu"> <h:panelGrid columns="2" border="10">
        <h:panelGroup>
            <h:panelGrid columns="1">
                <h:outputText value="Ваши конфигурации"/>
                <h:dataTable value="#{settingsforconfig.configList}" var="collectconfigs">
                    <h:column>
                        <h:commandLink value="#{collectconfigs.configName}"
                                       action="#{settingsforconfig.goOperationsPage}">
                            <f:setPropertyActionListener target="#{settingsforconfig.nowUsedConfig}"
                                                         value="#{collectconfigs.configName}"/>
                        </h:commandLink>
                    </h:column>
                </h:dataTable>
                <h:commandButton value="Загрузить новый конфиг" action="#{settingsforconfig.goLoadPage}"/>
            </h:panelGrid>
        </h:panelGroup>

        <h:panelGroup rendered="#{settingsforconfig.mode==0}">
            <h:outputText value="Загрузите ваш конфигурационный файл..."/>
        </h:panelGroup>

        <h:panelGroup rendered="#{settingsforconfig.mode==1}">
            <h:panelGrid columns="1">
                <h:outputLink value="/config/uploader.jsf" rendered="#{settingsforconfig.uploaded==false}">
                    <h:outputText value="Загрузить файл"/>
                </h:outputLink>
                <h:commandButton value="Сбросить" action="#{settingsforconfig.clearSettings}"
                                 rendered="#{settingsforconfig.uploaded==true}"/>
                <h:outputText value="#{settingsforconfig.oldFileName}" rendered="#{settingsforconfig.uploaded==true}"/>
                <h:outputText value="Выберите формат:" rendered="#{settingsforconfig.uploaded==true}"/>
                <h:selectOneListbox value="#{settingsforconfig.protocol}"
                                    rendered="#{settingsforconfig.uploaded==true}">
                    <f:selectItem itemValue="ini" itemLabel="ini"/>
                    <f:selectItem itemValue="xml" itemLabel="xml"/>
                    <f:selectItem itemValue="props" itemLabel="properties"/>
                </h:selectOneListbox>
                <h:commandButton value="Получить конфиги" action="#{settingsforconfig.goPresentPage}"
                                 rendered="#{settingsforconfig.uploaded==true}"/>
            </h:panelGrid>
        </h:panelGroup>

        <h:panelGroup rendered="#{settingsforconfig.mode==2}">
            <h:panelGrid columns="1">
                <h:outputText value="Файл конфигурации загружен"/>
                <h:panelGroup>
                    <h:outputText value="Название конфига:"/>
                    <h:outputText value="#{settingsforconfig.oldFileName}"/>
                </h:panelGroup>
                <h:panelGroup>
                    <h:panelGrid border="1" columns="1">
                        <h:panelGroup>
                            <h:outputText value="Заглавный комментарий  "/>
                            <h:outputText value="#{settingsforconfig.deltaConfig.configList.headerComment}"/>
                        </h:panelGroup>
                        <h:panelGroup>
                            <h:outputText value="Конечный комментарий  "/>
                            <h:outputText value="#{settingsforconfig.deltaConfig.configList.footerComment}"/>
                        </h:panelGroup>
                    </h:panelGrid>
                    <h:dataTable border="1" value="#{settingsforconfig.deltaConfig.configList.elements}"
                                 var="config">
                        <h:column>
                            <h:outputText value="#{config.key}"/>
                        </h:column>
                        <h:column>
                            <h:outputText value=" = "/>
                        </h:column>
                        <h:column>
                            <h:outputText value="#{config.value}"/>
                        </h:column>
                    </h:dataTable>
                    <h:commandButton value="Сохранить" action="#{settingsforconfig.extractSettings}"/>
                    <h:commandButton value="Отменить" action="#{settingsforconfig.cancelManipulations}"/>
                </h:panelGroup>
            </h:panelGrid>
        </h:panelGroup>

        <h:panelGroup rendered="#{settingsforconfig.mode==3}">
            <h:panelGrid columns="1">
                <h:panelGroup>
                    <h:outputText value="Редактирование конфига: "/>
                    <h:inputText value="#{settingsforconfig.deltaConfig.configName}"/>
                </h:panelGroup>
                <h:panelGrid border="1" columns="1">
                    <h:panelGroup>
                        <h:outputText value="Заглавный комментарий  "/>
                        <h:inputText value="#{settingsforconfig.deltaConfig.configList.headerComment}"/>
                    </h:panelGroup>
                    <h:panelGroup>
                        <h:outputText value="Конечный комментарий  "/>
                        <h:inputText value="#{settingsforconfig.deltaConfig.configList.footerComment}"/>
                    </h:panelGroup>
                </h:panelGrid>
                <h:dataTable border="1" value="#{settingsforconfig.deltaConfig.configList.elements}"
                             var="config">
                    <h:column>
                        <h:inputText value="#{config.key}"/>
                    </h:column>
                    <h:column>
                        <h:outputText value=" = "/>
                    </h:column>
                    <h:column>
                        <h:inputText value="#{config.value}"/>
                    </h:column>
                </h:dataTable>
                <h:panelGroup>
                    <h:commandButton value="Сохранить" action="#{settingsforconfig.saveEditedConfig}"/>
                    <h:commandButton value="Отмена" action="#{settingsforconfig.cancelManipulations}"/>
                </h:panelGroup>
                <h:commandButton value="Выгрузить конфиг" action="#{settingsforconfig.goDownloadPage}"/>
            </h:panelGrid>
        </h:panelGroup>

        <h:panelGroup rendered="#{settingsforconfig.mode==4}">
            <h:panelGrid columns="1" rendered="#{settingsforconfig.flagForDownload==false}">
                <h:panelGroup>
                <h:outputText value="Выгрузка - "/>
                <h:outputText value="#{settingsforconfig.deltaConfig.configName}"/>
                </h:panelGroup>
                <h:selectOneListbox value="#{settingsforconfig.protocol}">
                    <f:selectItem itemValue="ini" itemLabel="ini"/>
                    <f:selectItem itemValue="xml" itemLabel="xml"/>
                    <f:selectItem itemValue="props" itemLabel="properties"/>
                </h:selectOneListbox>
                <h:panelGroup>
                <h:commandButton value="Выгрузить конфиг" action="#{settingsforconfig.saveFile}"/>
                <h:commandButton value="Отмена" action="#{settingsforconfig.cancelManipulations}"/>
                </h:panelGroup>
            </h:panelGrid>
            <h:panelGrid columns="1" rendered="#{settingsforconfig.flagForDownload==true}">
            <h:outputLink value="/file/#{settingsforconfig.pathToDownloadFile}" rendered="#{settingsforconfig.flagForDownload==true}">
                <h:outputText value="Скачать #{settingsforconfig.deltaConfig.configName}"/>
            </h:outputLink>
            <h:commandButton value="Вернуться" action="#{settingsforconfig.goDefPageAfterDownload}"/>
            </h:panelGrid>
        </h:panelGroup>

    </h:panelGrid>
    </h:form>
</f:view>
</body>
</html>